import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  // 异步组件的按需导入方法
  { path: '/', redirect: '/login', hidden: true },
  { path: '/login', component: resolve => require(['@/views/login/index.vue'], resolve), hidden: true },
  {
    path: '/home',
    // import
    component: () => import('@/views/layout'),
    children: [{
      path: '',
      component: () => import('@/views/home'),
      meta: { title: '数据看板', icon: 'el-icon-time' }
    }
    ]
  },
  {
    path: '/article',
    component: () => import('@/views/layout'),
    children: [
      {
        path: '',
        component: () => import('@/views/article'),
        meta: { title: '面经管理', icon: 'el-icon-notebook-1' }
      }
    ]
  },
  { path: '/404', component: resolve => require(['@/views/404/index.vue'], resolve), hidden: true },
  { path: '*', redirect: '/404', hidden: true }
]

const router = new VueRouter({
  routes
})

export default router
